package la.iok.hzsvn.lewin.movie.operation.cfg;

import org.springframework.boot.context.properties.ConfigurationProperties;

/**
 * 网关服务的配置,主要是域名、端口、协议的配置,默认是https，443端口
 */
@ConfigurationProperties(prefix = "app.gateway.http")
public class ServerGatewayProperty {
    private String host;
    private int port = 443;
    private String scheme = "https";
    private String contextPath = "";

    public String getHost() {
        return host;
    }

    public void setHost(String host) {
        this.host = host;
    }

    public int getPort() {
        return port;
    }

    public void setPort(int port) {
        this.port = port;
    }

    public String getScheme() {
        return scheme;
    }

    public void setScheme(String scheme) {
        this.scheme = scheme;
    }

    public String getContextPath() {
        return contextPath;
    }

    public void setContextPath(String contextPath) {
        this.contextPath = contextPath;
    }

    public String hostPort(){
        if("https".equals(getScheme())){
            if(443 == getPort()){
                return getHost();
            }else{
                return getHost()+":"+getPort();
            }
        }else{
            if(80 == getPort()){
                return getHost();
            }else{
                return getHost()+":"+getPort();
            }
        }
    }
}
